﻿using System.Collections.Generic;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
using System.Linq;

namespace FPP.Models
{
    public partial class BachelorGame : EntityObject, IValidate
    {
        public BachelorGame(int id)
        {
            Id = id;
        }

        public int Id { get; set; }

        public string Name { get; set; }

        public bool Validate(ChangeAction action)
        {
            switch (action)
            {
                case ChangeAction.Insert:
                    if (string.IsNullOrEmpty(Name)) return false;
                    break;
            }

            return true;
        }

        public BachelorPerson Bachelor(FppRepository repository)
        {
            return repository.GetBachelorPerson(Id);
        }

        public BachelorPerson[] Contestants(FppRepository repository)
        {
            return repository.GetBachelorContestants(Id).ToArray();
        }
    }
}
